﻿@using Maanfee.Web.Printing
@page "/Prints/PrintView"
@inherits _ModulePage

<MaanfeeDashboardPage>
    <MaanfeeDashboardPageHeader PageTitle="@DashboardResource.StringPrint" Title="@DashboardResource.StringPrint" />

    <MudGrid>
        <MudItem md="12" xs="12">
            <h3>Size:@PrintSetting.PageSize,landscape:@PrintSetting.IsLandscape</h3>

            <MudStack Row="true" AlignItems="AlignItems.Start" Spacing="1">
                @foreach (var item in typeof(PageSize).GetFields())
                {
                    <MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@(_ => {PrintSetting.PageSize = item.GetValue(null)?.ToString();PrintSetting.IsLandscape = "false"; })">@item.Name</MudButton>
                    <MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@(_ => {PrintSetting.PageSize = item.GetValue(null)?.ToString();PrintSetting.IsLandscape = "true"; })">@item.Name Landscape</MudButton>
                }
            </MudStack>

            <h3>Padding:@PrintSetting.Padding</h3>

            <MudStack Row="true" AlignItems="AlignItems.Start" Spacing="1">
                @foreach (var item in typeof(Padding).GetFields())
                {
                    <MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@(_ => PrintSetting.Padding = item.GetValue(null)?.ToString())">@item.Name</MudButton>
                }
            </MudStack>

            <h3>Multiples:@PrintSetting.Multiple</h3>
            <MudStack Row="true" AlignItems="AlignItems.Start" Spacing="1">
                @foreach (var multiple in multiples)
                {
                    <MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@( _ => PrintSetting.Multiple = multiple)">@multiple</MudButton>
                }
            </MudStack>

            <h3>Auto Print:@PrintSetting.AutoPrint</h3>
            <MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@( _ => PrintSetting.AutoPrint="Yes")">Yes</MudButton>
            <MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@( _ => PrintSetting.AutoPrint="No")">No</MudButton>
        </MudItem>
        <MudItem md="6" xs="6">
            <MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@OnPrint">Print</MudButton>
        </MudItem>
        <MudItem md="6" xs="6">
            <MudButton Variant="Variant.Filled" Color="Color.Warning" OnClick="@OpenPrintDialog">Print Dialog</MudButton>
        </MudItem>
        <MudItem md="12" xs="12">
            @*@Http.BaseAddress.AbsoluteUri*@
            @*@Http.BaseAddress.DnsSafeHost | @Http.BaseAddress.Host | @Http.BaseAddress.Port | @Http.BaseAddress.Scheme*@
        </MudItem>
        <MudItem md="12" xs="12">

        </MudItem>
    </MudGrid>

</MaanfeeDashboardPage>

@code {

    protected override void OnInitialized()
    {

    }

    private string[] multiples = new[] { "1", "2", "3", "4", "5" };

    private void OnPrint()
    {
        Navigation.NavigateTo("/print");
    }

    private void OpenPrintDialog()
    {
        DialogParameters DialogParameters = new DialogParameters();

        var dialog = Dialog.Show<DialogPrint>(string.Empty, DialogParameters,
                new DialogOptions()
                    {
                        NoHeader = true,
                        FullScreen = true,
                    });
    }

}
